#!/bin/bash

# webhook 地址
WEBHOOK_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=e58eb86d-6879-40db-a44d-21ceee606b30"

# 要监控的进程名列表
PROCESS_NAMES=("wh5-electron-0" "wh5-electron-1" "wh5-electron-2" "wh5-electron-3" "wh5-electron-4")

for NAME in "${PROCESS_NAMES[@]}"; do
    STATUS=$(pm2 jlist | jq -r ".[] | select(.name==\"$NAME\") | .pm2_env.status")
    
    if [ "$STATUS" != "online" ]; then
        echo "$NAME is down!"
        #curl -X POST "$WEBHOOK_URL" -H "Content-Type: application/json" \
           #  -d "{\"text\":\"$NAME is down!\"}"
    fi
done